package com.czl.module_park.adapter

import android.os.Bundle
import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.czl.base.config.AppConstants
import com.czl.base.data.bean.ReverseSearchBean
import com.czl.module_park.R
import com.czl.module_park.databinding.ItemReveseSearchCarBinding
import com.sjzn.module_park.fragment.ReverseSearchCarFragment

class ReverseSearchCarListAdapter(val fragment: ReverseSearchCarFragment) :
    BaseQuickAdapter<ReverseSearchBean.DataItem, BaseDataBindingHolder<ItemReveseSearchCarBinding>>(
        R.layout.item_revese_search_car
    ) {
    override fun convert(
        holder: BaseDataBindingHolder<ItemReveseSearchCarBinding>,
        item: ReverseSearchBean.DataItem
    ) {
        holder.dataBinding?.apply {
            dataItem=item
            adapter=this@ReverseSearchCarListAdapter
            executePendingBindings()
        }

        holder.dataBinding?.let { Glide.with(context).load(item.carImgPath).into(it.ivReverseCarItem) }
        holder.dataBinding?.tvReveseListCarDetail?.setOnClickListener {
            fragment.startContainerActivity(
                AppConstants.Router.Park.F_REVERSE_CAR_SEARCH_DETAIL,
                Bundle().apply {
                    putSerializable(AppConstants.BundleKey.MONTH_CARD_DATA, item)
                }
            )
        }
    }



}